import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  /* {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },*/
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [{
      path: '/index',
      name: 'index',
      component: () => import('@/views/index'),
      meta: { title: '首页', icon: 'example' }
    }]
  },
  {
    path: '/admin',
    component: Layout,
    redirect: '/admin',
    children: [{
      path: '/admin',
      name: '组织管理',
      component: () => import('@/views/admin/index'),
      meta: { title: '组织管理', icon: 'example' }
    }]
  },
  {
    path: '/admin/details',
    component: Layout,
    redirect: '/admin/details',
    hidden: true,
    children: [{
      path: '/admin/details',
      name: '用户详情',
      component: () => import('@/views/admin/details'),
      meta: { title: '用户详情', icon: 'example' }
    }]
  },
  {
    path: '/athleteManagement',
    component: Layout,
    redirect: '/athleteManagement',
    children: [{
      path: '/athleteManagement',
      name: '运动员管理',
      component: () => import('@/views/athleteManagement/index'),
      meta: { title: '运动员管理', icon: 'example' }
    }]
  },
  {
    path: '/injurySystem',
    component: Layout,
    redirect: '/injurySystem',
    children: [{
      path: '/injurySystem',
      name: '伤病系统',
      component: () => import('@/views/injurySystem/index'),
      meta: { title: '伤病系统', icon: 'example' }
    },


    ]
  },
  {
    path: '/competitivePerf',
    component: Layout,
    redirect: '/competitivePerf',
    children: [{
      path: '/competitivePerf',
      name: '竞技表现',
      component: () => import('@/views/competitivePerf/index'),
      meta: { title: '竞技表现', icon: 'example' }
    },
    ]
  },



  {
    path: '/specializedTraining',
    component: Layout,
    redirect: '/specializedTraining',
    children: [{
      path: '/specializedTraining',
      name: '专项训练',
      component: () => import('@/views/specializedTraining/index'),
      meta: { title: '专项训练', icon: 'example' }
    },


    ]
  },
  {
    path: '/specializedTraining/details',
    component: Layout,
    redirect: '/specializedTraining/details',
    hidden: true,
    children: [{
      path: '/specializedTraining/details',
      name: '训练详情',
      component: () => import('@/views/specializedTraining/details'),
      meta: { title: '训练详情', icon: 'example' }
    }]
  },

  {
    path: '/functionMonitoring',
    component: Layout,
    redirect: '/functionMonitoring',
    children: [{
      path: '/functionMonitoring',
      name: '机能监控',
      component: () => import('@/views/functionMonitoring/index'),
      meta: { title: '机能监控', icon: 'example' }
    },


    ]
  },
  {
    path: '/physicalSummary',
    component: Layout,
    redirect: '/physicalSummary',
    children: [{
      path: '/physicalSummary',
      name: '体能汇总',
      component: () => import('@/views/physicalSummary/index'),
      meta: { title: '体能汇总', icon: 'example' }
    },


    ]
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/ArticleEditor',
  //   children: [{
  //     path: '/ArticleEditor',
  //     name: 'ArticleEditor',
  //     component: () => import('@/views/ArticleEditor'),
  //     meta: { title: '新增节点编辑', icon: 'form' }
  //   }]
  // },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/Contactusr',
  //   children: [{
  //     path: '/Contactus',
  //     name: 'Contactus',
  //     component: () => import('@/views/test/Contactus'),
  //     meta: { title: '学习推荐', icon: 'form' }
  //   }]
  // },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/askquestion',
  //   children: [{
  //     path: '/askquestion',
  //     name: 'askquestion',
  //     component: () => import('@/views/AskQuestion.vue'),
  //     meta: { title: '智能问答', icon: 'form' }
  //   }]
  // },

  /*{
    path: '/',
    component: Layout,
    redirect: '/Tree',
    children: [{
      path: '/Tree',
      name: 'Tree',
      component: () => import('@/views/Tree'),
      meta: { title: '导学模块', icon: 'tree' }
    }]
  },*/
  /*{
    path: '/',
    component: Layout,
    redirect: '/Todolist',
    children: [{
      path: '/Todolist',
      name: 'Todolist',
      component: () => import('@/views/Todolist'),
      meta: { title: 'Todo-List', icon: 'eye' }
    }]
  },*/
  /* {
     path: '/',
     component: Layout,
     redirect: '/Todo',
     children: [{
       path: '/Todo',
       name: 'Todo',
       component: () => import('@/views/Todo'),
       meta: { title: 'Todo-List', icon: 'eye' }
     }]
   },*/
  /*{
    path: '/',
    component: Layout,
    redirect: '/clicks',
    children: [{
      path: '/clicks',
      name: 'clicks',
      component: () => import('@/views/play/clicks'),
      meta: { title: '点击率统计', icon: 'eye' }
    }]
  },*/
  /*{
   path: '/',
   component: Layout,
   redirect: '/play',
   children: [{
     path: 'play',
     name: 'Play',
     component: () => import('@/views/play/play'),
     meta: { title: 'play', icon: '项目管理' }
   }]
 },*/
  /*{
    path: '/2dView',
    name: '2dView',
    // route level code-splitting
    //  this generates a separate chunk (about.[hash].js) for this route
    //  which is lazy-loaded when the route is visited.
    component: () => import(/!* webpackChunkName: "about" *!/ '../views/2dView.vue')
  },
  {
    path: '/tmp',
    component: Layout,
    redirect: '/tmp',
    meta: { title: '实验测试', icon: 'testmanger' },
    children: [
      {
        path: '/tjcs',
        name: 'tjcs',
        component: () => import('@/views/play/tjcs'),
        meta: { title: '提交测试', icon: 'request' }
      },*/
  /* {
    path: '/test',
    name: 'test',
    component: () => import('@/views/test/index'),
    meta: { title: '提测管理', icon: 'request' }
  },*/
  /*{
    path: '/commit',
    name: 'commit',
    hidden: true,
    component: () => import('@/views/test/manger/commit'),
    meta: { title: '需求提测' }
  },
  {
    path: '/report',
    name: 'report',
    hidden: true,
    component: () => import('@/views/test/manger/report'),
    meta: { title: '测试报告' }
  },
  {
    path: 'mytest',
    name: 'mytest',
    component: () => import('@/views/test/mydev'),
    meta: { title: '我的提测', icon: 'mydev' }
  },
  {
    path: 'mydev',
    name: 'mydev',
    component: () => import('@/views/test/mydev'),
    meta: { title: '我的测试', icon: 'mytest' }
  }
]
},
{
path: '/',
component: Layout,
redirect: '/play',
children: [{
  path: '/play',
  name: 'play',
  component: () => import('@/views/play/play'),
  meta: { title: '实验管理', icon: '项目管理' }
}]
},*/
  /* {
    path: '/settings',
    component: Layout,
    redirect: '/settings',
    meta: { title: '实验管理', icon: '项目管理' },
    children: [
      {
        path: 'play',
        name: 'play',
        component: () => import('@/views/play/play'),
        meta: { title: '1', icon: '应用管理' } // icon是页面上的小图标
        /!*  增删改查功能测试  *!/
      },
      {
        path: 'play2',
        name: 'play2',
        component: () => import('@/views/play/play2'),
        meta: { title: '分页功能', icon: 'mydev' }
        /!*  分页功能测试  *!/
      }
    ]
  },*/
  /*{
    path: '/',
    component: Layout,
    redirect: '/play2',
    children: [{
      path: '/play2',
      name: 'play2',
      component: () => import('@/views/play/play2'),
      meta: { title: '问答模块', icon: 'link' }
    }]
  },*/
  /* {
    path: '/settings',
    component: Layout,
    redirect: '/settings',
    meta: { title: '基础管理', icon: '设置' },
    children: [{
      path: 'product',
      name: 'Product',
      component: () => import('@/views/product/product'),
      meta: { title: '项目产品分类', icon: '项目管理' }
    },
    {
      path: 'apps',
      name: 'apps',
      component: () => import('@/views/product/apps'),
      meta: { title: '服务应用管理', icon: '应用管理' }
    }
    ]
  }, */
  {
    path: '/demo',
    component: Layout,
    redirect: '/demo',
    hidden: true,
    meta: { title: 'else', icon: '设置' },
    children: [{
      path: 'upload',
      name: 'Upload',
      component: () => import('@/views/demo/uploadDemo'),
      meta: { title: '文件上传Demo' }
    },
    {
      path: 'chart',
      name: 'chart',
      component: () => import('@/views/demo/echartsDemo'),
      meta: { title: 'Echarts Demo' }
    }]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
